The code below assumes that the Main Report PrintJob is already open.
PEGetNSections PEGetSectionCode PEGetNSubreportsInSection PEGetNthSubreportInSection PEGetSubreportInfo
uses CRDelphi; procedure GetSubreportInfo; var SubreportHandle : LongInt; SubreportInfo : PESubreportInfo; nSections, nSubReports : smallint; nSection, nSubreport : smallint; SectionCode : smallint; SubReportName : string; NLinks : smallint; OnDemand : smallint; begin {Set the structure size} SubreportInfo.Structsize := SizeOf(PESubreportInfo); {Get the # of Sections in the Report} nSections := PEGetNSections(PrintJob); if nSections =-1 then {Do Error Handler}; {Loop through the Sections} for nSection := 0 to (nSections - 1) do begin SectionCode := PEGetSectionCode(PrintJob, nSection); nSubReports := PEGetNSubreportsInSection(PrintJob, SectionCode); if nSubReports > 0 then begin for nSubreport := 0 to nSubReports - 1 do begin {Get the Subreport Handle} SubreportHandle := PEGetNthSubreportInSection(PrintJob, SectionCode, nSubreport); {Get the Subreport Name} if not PEGetSubreportInfo(PrintJob, SubreportHandle, SubreportInfo) then {Do Error Handler}; {Get SubreportName and other information} {Normally these would be stored to stringlists, or something similar} SubReportName := (StrPas(@SubreportInfo.SubreportName)); NLinks := SubreportInfo.NLinks; OnDemand := SubreportInfo.isOnDemand; end; end; end; end;
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |